package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPublicationCompletionForSuperView;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationCompletionForSuperModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationCompletionForSuperModel;

/**
 * Created by tony on 2018/6/18.
 */

public class PublicationCompletionForSuperPresenter {
    private IPublicationCompletionForSuperView view;
    private IPublicationCompletionForSuperModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationCompletionForSuperPresenter(IPublicationCompletionForSuperView view) {
        this.view = view;
        this.model = new PublicationCompletionForSuperModel();
    }

    public void publicationCompletionForSuper() {


        model.publicationCompletionForSuper(view.getOrderId(), new PublicationCompletionForSuperModel.OnPublicationCompletionForSuperListener() {
            @Override
            public void publicationCompletionForSuperSunccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationCompletionForSuperSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void publicationCompletionForSuperFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationCompletionForSuperFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
